package com.platform.qujia.service.impl;

import com.platform.qujia.pojo.WxMessageTemplate;
import com.platform.qujia.service.WxTemplateParamsGeneral;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

@Component("wxTemplateRefuelSuccess")
public class WxTemplateRefuelSuccessParams implements WxTemplateParamsGeneral {

    /**
     * 汽油油品：{{keyword1.DATA}}
     * 加油金额：{{keyword2.DATA}}
     * 实扣储油：{{keyword3.DATA}}
     * 实付金额：{{keyword4.DATA}}
     * 支付方式：{{keyword5.DATA}}
     *
     * @return
     */
    @Override
    public void setWxTemplateContent(List<String> contents, Map<String, String> templateParams, Map<String, Map<String, String>> data) {
        if (contents.contains("油站名称")) {
            data.put("thing2", Collections.singletonMap("value", templateParams.get("stationName")));
        }
        if (contents.contains("油品名称")) {
            data.put("thing11", Collections.singletonMap("value", templateParams.get("oilName")));
        }
        if (contents.contains("付款明细")) {
            data.put("thing4", Collections.singletonMap("value", templateParams.get("payDetail")));
        }
        if (contents.contains("钱包余额")) {
            data.put("amount9", Collections.singletonMap("value", templateParams.get("walletBalance")));
        }
        if (contents.contains("消费时间")) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            data.put("time10", Collections.singletonMap("value", formatter.format(LocalDateTime.now())));
        }
    }
}
